//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package ciicos.iview.controller;

import ciicos.base.ActionResult;
import ciicos.iview.service.IviewService;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/api/iviewManage"})
public class IviewController {
    private static final Logger log = LoggerFactory.getLogger(IviewController.class);
    @Autowired
    private IviewService iviewService;

    @GetMapping({"/userlogin"})
    public ActionResult userlogin(@RequestParam(name = "user",required = true) String user, @RequestParam(name = "pass",required = true) String pass) {
        String realdata = this.iviewService.userlogin(user, pass);
        return ActionResult.success(JSONObject.parse(realdata));
    }

    @GetMapping({"/userlogout"})
    public ActionResult userlogout(@RequestParam(name = "token",required = true) String token) {
        String realdata = this.iviewService.userlogout(token);
        return ActionResult.success(JSONObject.parse(realdata));
    }

    @GetMapping({"/realdata3"})
    public ActionResult realdata(@RequestParam(name = "token",required = false) String token, @RequestParam(name = "tags",required = true) String tags, @RequestParam(name = "pars",required = true) String pars, @RequestParam(name = "decimal",required = false) Integer decimal, @RequestParam(name = "valueonly",required = false) Integer valueonly) {
        String realdata = this.iviewService.realdata(token, tags, pars, decimal, valueonly);
        return ActionResult.success(JSONObject.parse(realdata));
    }

    @GetMapping({"/realdata4"})
    public ActionResult realdata(@RequestParam(name = "token",required = false) String token, @RequestParam(name = "names",required = true) String names, @RequestParam(name = "decimal",required = false) Integer decimal, @RequestParam(name = "valueonly",required = false) Integer valueonly) {
        String realdata = this.iviewService.realdata(token, names, decimal, valueonly);
        return ActionResult.success(JSONObject.parse(realdata));
    }

    @GetMapping({"/realdir5"})
    public ActionResult realdir(@RequestParam(name = "token",required = false) String token, @RequestParam(name = "subnode",required = false) String subnode, @RequestParam(name = "recursion",required = false) Integer recursion, @RequestParam(name = "valueonly",required = false) Integer valueonly, @RequestParam(name = "decimal",required = false) Integer decimal) {
        String realdir = this.iviewService.realdir(token, subnode, recursion, valueonly, decimal);
        return ActionResult.success(JSONObject.parse(realdir));
    }

    @GetMapping({"/realdata9"})
    public ActionResult realdata(@RequestParam(name = "token",required = false) String token, @RequestParam(name = "body",required = true) String body) {
        String realdata = this.iviewService.realdata(token, body);
        return ActionResult.success(JSONObject.parse(realdata));
    }

    @GetMapping({"/hisdata11"})
    public ActionResult hisdata(@RequestParam(name = "token",required = false) String token, @RequestParam(name = "times",required = true) String times, @RequestParam(name = "names",required = true) String names, @RequestParam(name = "decimal",required = false) Integer decimal, @RequestParam(name = "valueonly",required = false) Integer valueonly) {
        String hisdata = this.iviewService.hisdata(token, times, names, decimal, valueonly);
        return ActionResult.success(JSONObject.parse(hisdata));
    }

    @GetMapping({"/hisdata12"})
    public ActionResult hisdata(@RequestParam(name = "token",required = false) String token, @RequestParam(name = "startTime",required = true) String startTime, @RequestParam(name = "endTime",required = true) String endTime, @RequestParam(name = "interval",required = true) Integer interval, @RequestParam(name = "names",required = true) String names, @RequestParam(name = "decimal",required = false) Integer decimal, @RequestParam(name = "valueonly",required = false) Integer valueonly) {
        String hisdata = this.iviewService.hisdata(token, startTime, endTime, interval, names, decimal, valueonly);
        return ActionResult.success(JSONObject.parse(hisdata));
    }
}
